#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define maxn 100005

#define rep(i, l, r) for (int i = (l); i <= (r); i++)

struct Project {
  ll cost;
  ll price;
} project[maxn];

ll n, k, m;
int pos = 1;
int cnt = 0;

bool cmp(Project a, Project b) { return a.cost < b.cost; }

int main() {
  cin >> n >> k >> m;
  for (int i = 1; i <= n; i++) {
    cin >> project[i].cost >> project[i].price;
  }

  sort(project + 1, project + 1 + n, cmp);

  priority_queue<ll> q;
  while (cnt < k) {
    while (pos <= n && project[pos].cost <= m) {
      q.push(project[pos].price);
      pos++;
    }
    if (q.empty())
      break;
    ll premium = q.top();
    q.pop();
    m = m + premium;
    cnt++;
  }

  cout << m;

  return 0;
}